home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 10 / FM Towns Free Software Collection 10.iso / tos_updt / fmcity / palcom / auto / script / formsel.mx < prev    next >
Text File  |  1995-04-17  |  12KB  |  377 lines

  1. //--------------------------------------------------------------------------//
  2. //                        PALCOM V2.1 L10                        //
  3. //                自動通信:巡回フォーラム選択ダイアログスクリプト            //
  4. //                                                                            //
  5. //                                        CopyRight(C) 1994/10/20                //
  6. //                                FUJITSU PERSONAL COMPUTER SYSTEMS LIMITED    //
  7. //                                        written by C-cube Soft T.Nakamura    //
  8. //--------------------------------------------------------------------------//
  9. event    @OPEN.EXTERN {
  10.     //---   データの取得   ---//
  11.     $topList       = Auto.getForumTop();
  12.     $forumNum      = list.get1st( $topList );
  13.     $topList       = list.getNth( $topList, 2 );
  14.     $SetStatusList = list.getNth( $topList, 1 );
  15.     $StatusList    = list.getNth( $topList, 2 );
  16.     $NameList      = list.getNth( $topList, 3 );
  17.     $CmdList       = list.getNth( $topList, 4 );
  18.     $TagList       = list.getNth( $topList, 5 );
  19.     $chkNumList    = list.getNth( $topList, 6 );
  20.  
  21.     $i = 1;
  22.     $ListNameList = [];
  23.     foreach( $a, $NameList ) {
  24.         if( list.getNth( $StatusList, $i ) == #TRUE ) {
  25.             $mark = "■";
  26.         } elif( list.getNth( $SetStatusList, $i ) == #TRUE ) {
  27.             $mark = "□";
  28.         } else {
  29.             $mark = "  ";
  30.         }
  31.         list.putLast( $ListNameList, str.join([$mark,$a], "" ));
  32.         $i = $i + 1;
  33.     }
  34.     $defList = [1];
  35.  
  36.     sys.global( $NameList      );
  37.     sys.global( $StatusList    );
  38.     sys.global( $SetStatusList );
  39.     sys.global( $ListNameList  );
  40.     sys.global( $TagList       );
  41.  
  42.     //---   フォーラムが1件も登録されていない場合   ---//
  43.     //---                       直接新規登録を行う。 ---//
  44.     if( list.size( $NameList ) == 0 ) {
  45.         $dataList = ["","",[-1,-1,-1],#FALSE,#TRUE];
  46.         AUTO.setForumData( $dataList, time.get());
  47.         $path = str.join([$$DIR.STANDARD, "AUTO\\SCRIPT\\FORMEDIT.MX"], "" );
  48.         script.openExtern( $path, #FALSE, [] );
  49.         if( AUTO.getDialogReturn() != 1 ) {
  50.             AUTO.setDialogReturn( 0 );
  51.             return;
  52.         } else {
  53.             AUTO.updateForumData( $topList, -1 );
  54.             Auto.setListName( -1 );
  55.         }
  56.     }
  57.  
  58.     //---   ボタンの設定   ---//
  59.     $newBtnId  =  dialog.makeButton( 1, "新規登録", 0,      0 );
  60.     $editBtnId =  dialog.makeButton( 1, "編集",     0,      0 );
  61.     $loopBtnId =  dialog.makeButton( 1, "巡回",     0,      0 );
  62.     $delBtnId  =  dialog.makeButton( 1, "削除",     0, 0x007F );
  63.     $setBtnId  =  dialog.makeButton( 1, "設定",     0, 0x8012 );
  64.     $canBtnId  =  dialog.makeButton( 1, "取消",     0, 0x8011 );
  65.  
  66.     //---   ダイアログデータの設定   ---//
  67.     $dialogList = ["巡回フォーラムの設定", 0, -1, -1, $setBtnId,
  68.             ["", 1028,       [60,10,0], $ListNameList, $defList    ],
  69.             ["", $canBtnId,  [0],       [""],          [""]        ],
  70.             ["", $setBtnId,  [0],       [""],          [""]        ],
  71.             ["", $delBtnId,  [0],       [""],          [""]        ],
  72.             ["", $loopBtnId, [0],       [""],          [""]        ],
  73.             ["", $editBtnId, [0],       [""],          [""]        ],
  74.             ["", $newBtnId,  [0],       [""],          [""]        ]];
  75.  
  76.     //---   メインループ   ---//
  77.     loop {
  78.         //---   ダイアログの表示   ---//
  79.         sys.pushCursor( 80 );
  80.         dialog.open( $dialogList );
  81.         sys.popCursor();
  82.  
  83.         //---   ボタンの処理   ---//
  84.         $btnId = list.get1st( $$DIALOG.RETURN );
  85.         $no    = list.get1st( list.getNth( $$DIALOG.RETURN, 2 ));
  86.  
  87.         //---   選択されていなくては実行出来ない物のチェック   ---//
  88.         if(( $btnId == $loopBtnId )||( $btnId == $editBtnId )||
  89.            ( $btnId == $delBtnId )) {
  90.             if(( $no == -1 )||( list.size( $NameList ) == 0 )) {
  91.                 continue;
  92.             }
  93.         }
  94.  
  95.         $exitFlg = 0;
  96.         table( $btnId ) {
  97.             else        { $exitFlg = 1;    }
  98.             $canBtnId    { $exitFlg = 1;    }
  99.             $setBtnId    { $exitFlg = 1;    }
  100.             $newBtnId    {
  101.                 if( $forumNum == AUTO.getForumMax()) {
  102.                     $saveXsize = dialog.getDefaultXSize();
  103.                     dialog.setDefaultXSize( 328 );
  104.                     sys.pushCursor( 80 );
  105.                     $ret = dialog.ask([
  106.                         "━━━━━━   フォーラムの新規登録   ━━━━━━",
  107.                         "",
  108.                         "  登録可能なフォーラムの最大数を超えました。      ",
  109.                         "  さらにフォーラムを登録する場合は、一度自動通信を",
  110.                         "終了させ、再度設定を行ってください。              ",
  111.                         ""], ["確認"] );
  112.                     sys.popCursor();
  113.                     dialog.setDefaultXSize( $saveXsize );
  114.                     exit;
  115.                 }
  116.                 $dataList = ["","",[-1,-1,-1],#FALSE,#TRUE];
  117.                 AUTO.setForumData( $dataList, time.get());
  118.                 $path = str.join([$$DIR.STANDARD,
  119.                                   "AUTO\\SCRIPT\\FORMEDIT.MX"], "" );
  120.                 script.openExtern( $path, #FALSE, [] );
  121.                 if( AUTO.getDialogReturn() == 1 ) {
  122.                     AUTO.updateForumData( $topList, -1 );
  123.                     Auto.setListName( -1 );
  124.                     $forumNum = $forumNum + 1;
  125.                 }
  126.             }
  127.             $editBtnId    {
  128.                 $dataList = [list.getNth( $NameList,      $no ),
  129.                              list.getNth( $CmdList,       $no ),
  130.                              list.getNth( $TagList,       $no ),
  131.                              list.getNth( $SetStatusList, $no ),
  132.                              list.getNth( $StatusList,    $no )];
  133.                 AUTO.setForumData( $dataList, list.getNth( $chkNumList, $no ));
  134.                 $path = str.join([$$DIR.STANDARD,
  135.                                   "AUTO\\SCRIPT\\FORMEDIT.MX"], "" );
  136.                 script.openExtern( $path, #FALSE, [] );
  137.                 if( AUTO.getDialogReturn() == 1 ) {
  138.                     AUTO.updateForumData( $topList, $no );
  139.                     Auto.setListName( $no );
  140.                 }
  141.             }
  142.             $loopBtnId    {
  143.                 if( list.getNth( $SetStatusList, $no ) == #FALSE ) {
  144.                     exit;
  145.                 }
  146.                 if( list.getNth( $StatusList, $no ) == #FALSE ) {
  147.                     list.delNth( $StatusList, $no );
  148.                     list.putNth( $StatusList, $no-1, #TRUE );
  149.                 } else {
  150.                     list.delNth( $StatusList, $no );
  151.                     list.putNth( $StatusList, $no-1, #FALSE );
  152.                 }
  153.                 Auto.setListName( $no );
  154.                 list.del1st( $defList );
  155.                 list.put1st( $defList, $no );
  156.                 $upDateFlg = 1;
  157.             }
  158.             $delBtnId    {
  159.                 if(( $ret = DelAuto( $no )) == 0 ) {
  160.                     exit;
  161.                 }
  162.                 if( $ret == 1 ) {
  163.                     list.del1st( $defList );
  164.                     list.put1st( $defList, $no );
  165.                 } else {
  166.                     $forumNum = $forumNum - 1;
  167.                     if( $no != 1 ) {
  168.                         list.del1st( $defList );
  169.                         list.put1st( $defList, $no - 1 );
  170.                     }
  171.                 }
  172.                 $upDateFlg = 1;
  173.             }
  174.         }
  175.         if( $exitFlg == 1 ) {
  176.             exit;
  177.         }
  178.     }
  179.  
  180.     //---   復帰値の設定&後始末   ---//
  181.     if( $btnId == $setBtnId ) {
  182.         if( $upDateFlg == 1 ) {
  183.             AUTO.setLoopStatus( $StatusList, $TagList );
  184.         }
  185.         $btnId =  1;
  186.     } elif( $btnId == $canBtnId ) {
  187.         $btnId =  0;
  188.     } else {
  189.         $btnId = -1;
  190.     }
  191.     AUTO.setDialogReturn( $btnId );
  192.  
  193.     sys.local( $TagList       );
  194.     sys.local( $ListNameList  );
  195.     sys.local( $StatusList    );
  196.     sys.local( $SetStatusList );
  197.     sys.local( $NameList      );
  198.     dialog.delButton( $newBtnId  );
  199.     dialog.delButton( $editBtnId );
  200.     dialog.delButton( $loopBtnId );
  201.     dialog.delButton( $delBtnId  );
  202.     dialog.delButton( $setBtnId  );
  203.     dialog.delButton( $canBtnId  );
  204.     return;
  205. }
  206. event    @CLOSE.EXTERN    {
  207.     return;
  208. }
  209. event    @ERROR    {
  210.     local.errorFunc();
  211.     event.mainLoop();
  212. }
  213.  
  214.  
  215.  
  216. //--------------------------------------------//
  217. //---   自動通信設定の削除ダイアログ制御   ---//
  218. //--------------------------------------------//
  219. function    DelAuto( $no ) {
  220.     $str = str.join(["【", list.getNth( $NameList, $no ),"】",
  221.                                                 "の設定を削除します。"], "" );
  222.  
  223.     $setBtnId = dialog.makeButton( 1, "実行", 0, 0x8012 );
  224.     $canBtnId = dialog.makeButton( 1, "取消", 0, 0x8011 );
  225.  
  226.     $dialogList = ["", 0, -1, -1, $setBtnId,
  227.         ["", 1024,      [0], [
  228.         "━━━━━━━━━━  フォーラム設定の削除  ━━━━━━━━━━"],
  229.                                                                     [""]],
  230.         ["", 1024,      [0], [""],                                  [""]],
  231.         ["", 1024,      [2], [$str],                                [""]],
  232.         ["", 1024,      [0], [""],                                  [""]],
  233.         ["", 1026,      [1], ["フォーラムの登録情報を削除する"],[#FALSE]],
  234.         ["", 1024,      [0], [""],                                  [""]],
  235.         ["", 1024,      [0], [
  236.             "     フォーラムの登録情報を削除すると、他の自動通信設定で指定",
  237.             "   されている同フォーラムへの巡回も行われなくなります。      "],
  238.                                                                     [""]],
  239.         ["", 1024,      [0], [""],                                  [""]],
  240.         ["", $canBtnId, [0], [""], [""]],
  241.         ["", $setBtnId, [0], [""], [""]]
  242.     ];
  243.  
  244.     $saveXsize = dialog.getDefaultXSize();
  245.     dialog.setDefaultXSize( 408 );
  246.     sys.pushCursor( 80 );
  247.     dialog.open( $dialogList );
  248.     sys.popCursor();
  249.     dialog.setDefaultXSize( $saveXsize );
  250.  
  251.     dialog.delButton( $canBtnId );
  252.     dialog.delButton( $setBtnId );
  253.  
  254.     $btnId = list.get1st( $$DIALOG.RETURN );
  255.  
  256.     if( $btnId == $setBtnId ) {
  257.         $delFlg = list.get1st( list.getNth( $$DIALOG.RETURN, 6 ));
  258.         AUTO.delForumData( list.getNth( $TagList, $no ), $delFlg );
  259.         if( $delFlg == #FALSE ) {
  260.             list.delNth( $StatusList,    $no );
  261.             list.putNth( $StatusList,    $no - 1, #FALSE );
  262.             list.delNth( $SetStatusList, $no );
  263.             list.putNth( $SetStatusList, $no - 1, #FALSE );
  264.             list.delNth( $ListNameList,  $no );
  265.             list.putNth( $ListNameList,  $no - 1,
  266.                         str.join( ["  ", list.getNth( $NameList, $no )], "" ));
  267.             return( 1 );
  268.         } else {
  269.             list.delNth( $StatusList,    $no );
  270.             list.delNth( $SetStatusList, $no );
  271.             list.delNth( $ListNameList,  $no );
  272.             list.delNth( $NameList,      $no );
  273.             list.delNth( $TagList,       $no );
  274.             return( 2 );
  275.         }
  276.     }
  277.     return( 0 );
  278. }
  279.  
  280. //----------------------------------------//
  281. //---   リストに表示する文字列の設定   ---//
  282. //----------------------------------------//
  283. function    Auto.setListName( $no ) {
  284.     if( list.getNth( $StatusList, $no ) == #TRUE ) {
  285.         $mark = "■";
  286.     } elif( list.getNth( $SetStatusList, $no ) == #TRUE ) {
  287.         $mark = "□";
  288.     } else {
  289.         $mark = "  ";
  290.     }
  291.     $str = str.join( [$mark, list.getNth( $NameList, $no )], "" );
  292.     if( $no == -1 ) {
  293.         list.putLast( $ListNameList, $str );
  294.     } else {
  295.         list.delNth( $ListNameList, $no );
  296.         list.putNth( $ListNameList, $no-1, $str );
  297.     }
  298.     return;
  299. }
  300.  
  301. //------------------------------------//
  302. //---   フォーラム巡回情報の取得   ---//
  303. //------------------------------------//
  304. function    Auto.getForumTop() {
  305.     $nameList    = [];
  306.     $cmdList     = [];
  307.     $statusList1 = [];
  308.     $statusList2 = [];
  309.     $chkNumList  = [];
  310.     $tagList     = [];
  311.     $tag         = [1, 2, -5, -2];
  312.  
  313.     //---   データベースに登録されているフォーラムの個数を調べる   ---//
  314.     $TrdId = AUTO.getTrdId();
  315.     $num = trd.count( $TrdId, $tag );
  316.     if( $num == 0 ) {
  317.         return( [0, [[],[],[],[],[],[]]] );
  318.     }
  319.  
  320.     //---   フォーラム情報の読み込み   ---//
  321.     $SetDataList = AUTO.getSetData();
  322.     if( dialog.check() == #FALSE ) {
  323.         $dlgFlg = #TRUE;
  324.         dialog.openProg([[],"フォーラム情報を読み込んでいます",[],""],
  325.                                                                 "", #TRUE );
  326.     } else {
  327.         $dlgFlg = #FALSE;
  328.     }
  329.     $cnt = 0;
  330.     loop {
  331.         $retList = trd.getData( $TrdId, $tag );
  332.         if( list.get1st( $retList ) == 0 ) {
  333.             exit;
  334.         }
  335.  
  336.         $wkList = str.split( list.getNth( $retList, 2 ), "\t" );
  337.         $chkNum = data.toNumber( list.getNth( $wkList, 3 ));
  338.  
  339.         $forumId = list.getNth( list.getNth( $retList, 3 ), 3 );
  340.         $status1 = #FALSE;
  341.         $status2 = #FALSE;
  342.         foreach( $a, list.getNth( $SetDataList, 2 )) {
  343.             if(( $forumId == list.getNth( list.get1st( $a ),    3 ))&&
  344.                ( $chkNum  == list.getNth( list.getNth( $a, 2 ), 4 ))) {
  345.                 $status1 = #TRUE;
  346.                 $status2 = list.get1st( list.get1st( list.get1st(
  347.                                                     list.getNth( $a, 2 ))));
  348.                 exit;
  349.             }
  350.         }
  351.         list.putLast( $cmdList,     list.getNth( $wkList, 1 ));
  352.         list.putLast( $nameList,    list.getNth( $wkList, 2 ));
  353.         list.putLast( $chkNumList,  $chkNum  );
  354.         list.putLast( $statusList1, $status1 );
  355.         list.putLast( $statusList2, $status2 );
  356.         $tag = list.getNth( $retList, 3 );
  357.         loop {
  358.             if( list.getLast( $tag ) <= 0 ) {
  359.                 list.delLast( $tag );
  360.                 continue;
  361.             }
  362.             exit;
  363.         }
  364.         list.putLast( $tagList, $tag );
  365.         $tag = [];
  366.         $cnt = $cnt + 1;
  367.         if( $dlgFlg == #TRUE ) {
  368.             dialog.updateProg( $cnt * 100 / $num );
  369.         }
  370.     }
  371.     if( $dlgFlg == #TRUE ) {
  372.         dialog.close();
  373.     }
  374.     return( [$num, [$statusList1,$statusList2,$nameList,
  375.                                             $cmdList,$tagList,$chkNumList]] );
  376. }
  377.